/**
 * Project Name:springBoot-service
 * File Name:XmlComponent.java
 * Package Name:com.libra.service.utils
 * Date:2018年10月31日下午1:47:43
 * Copyright (c) 2018, wangzhch All Rights Reserved.
 *
*/

package com.libra.service.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.fastjson.JSON;
import com.libra.model.xml.TestManyNodeXml;
import com.libra.model.xml.TestOneNodeXml;
import com.libra.model.xml.TestRoundNodeXml;

/**
 * ClassName:XmlComponent <br/>
 * Date:     2018年10月31日 下午1:47:43 <br/>
 * @author   wangzhch
 * @version  
 * @since    JDK 1.8
 * @see 	 
 */
public class FreamXmlComponent {

	private static Logger log = LoggerFactory.getLogger(FreamXmlComponent.class);
	/**
	 * 
	 * testOneNodeXml:(1.使用模板组装单个节点的xml报文<单节点>). <br/>
	 * @author wangzhch
	 * @param testXml
	 * @return
	 * @since JDK 1.8
	 */
	public static Map<String, Object> testOneNodeXml(TestOneNodeXml testXml) {
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("main", testXml.getMain());
		return map;
	}

	/**
	 * 
	 * testManyNodeXml:(2.使用模板组装2个以上节点的xml报文<多节点>). <br/>
	 * @author wangzhch
	 * @param testManyNodeXml
	 * @return
	 * @since JDK 1.8
	 */
	public static Map<String, Object> testManyNodeXml(TestManyNodeXml testManyNodeXml) {
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("main", testManyNodeXml.getMain());
		map.put("test", testManyNodeXml.getTest());
		return map;
	}

	/**
	 * 
	 * testRoundNodeXml:(3.list节点循环). <br/>
	 * @author wangzhch
	 * @param testRoundNodeXml
	 * @return
	 * @since JDK 1.8
	 */
	public static Map<String, Object> testRoundNodeXml(TestRoundNodeXml testRoundNodeXml) {
		Map<String, Object> map = new HashMap<String,Object>();
		log.info("List:{}",JSON.toJSONString(testRoundNodeXml.getMain()));
		map.put("mains", testRoundNodeXml.getMain());
		map.put("test", testRoundNodeXml.getTest());
		return map;
	}
	
	public static void main(String[] args) {
		List<Map<String,String>> list = new ArrayList<>();
		Map<String,String> map = new HashMap<>();
		map.put("name", "kity");
		map.put("age", "23");
		list.add(map);
		Map<String,String> map2 = new HashMap<>();
		map2.put("name", "kity");
		map2.put("age", "23");
		list.add(map2);
		System.out.println(JSON.toJSONString(list));
	}
	
}

